#ifndef RSDECODE_H
#define RSDECODE_H

class RSdecode
{
public:
    RSdecode();


    int calcSigmaMBM(int *sigma, int *omega, int *syn);
    int decode(int *data, int length, bool noCorrect);
    int decode(int *data, int length);
    int decode(int *data);

    void setNpar(int a);

private:
    int RS_PERM_ERROR;
    int RS_CORRECT_ERROR;

    ///galois config
    int POLYNOMIAL;
    int expTbl[255*2];
    int logTbl[255 + 1];
    int npar;

private:
    ///galois methods
    void initGaloisTable();
    void mulPoly(int *seki, int *a, int *b) ;
    bool calcSyndrome(int *data, int length, int *syn);

    int toExp(int a);
    int toLog(int a);
    int toPos(int lenght, int a);
    int mul(int a, int b);
    int mulExp(int a, int b);
    int div(int a, int b);
    int divExp(int a, int b);
    int inv(int a);

    ///<---galois methods

    int chienSearch(int *pos, int n, int jisu, int *sigma);

    void doForney(int *data, int length, int jisu, int *pos, int *sigma, int *omega);
};

#endif // RSDECODE_H
